// @flow
import configure, { sagaMiddleware } from './configure';
import modules from './modules'; // 引用具体reducer模块
// import type { Auth } from './modules/auth';
// import type { User } from './modules/user';
// import type { Base } from './modules/base';
import { type Things, RootSaga as ThingSaga } from './modules/things';
// import type { Posts } from './modules/posts';
// import type { Sample } from './modules/sample';
// import type { Listing } from './modules/listing';
// import type { ProfileState } from './modules/profile';
// import type { FollowState } from './modules/follow';
import type { Common } from './modules/common';
import type { Pay } from './modules/pay';
// import type { SettingsState } from './modules/settings';

const store = configure();

// then run the saga
modules.sagas.map((item) => {
  if (item !== undefined && item !== null) {
    sagaMiddleware.run(item);
  }
});
// sagaMiddleware.run(ThingSaga);
export default store;

export type State = {
  // auth: Auth,
  // user: User,
  // base: Base,
  things: Things,
  pay: Pay,
  // sample: Sample,
  // listing: Listing,
  // profile: ProfileState,
  // follow: FollowState,
  common: Common,
  // settings: SettingsState,
};
